angular.module("myApp")
.controller("ShopControllerChild", ["$scope","$element","ShopServiceChild", function($scope,$element,ShopServiceChild){
	ShopServiceChild.getData().success(function(res){
		$scope.items=res.data.list;
		$scope.c3=false;
		$scope.price="price";
		$scope.extras=res.data.extra;
		$scope.change=false;
		$scope.arrs=res.data.filters.poi;
		$scope.limits=res.data.filters.extra;
		$scope.lengths=res.data.filters.poi[1].country;
		$scope.pros=res.data.filters.order;
		/*点击li  实现切换*/
		$scope.fun = function(e){
			var lis=document.querySelectorAll(".shopChild_AllDirection_li");
			for(var j=0;j<lis.length;j++){
				lis[j].style.backgroundColor="#dfdfdf";
				lis[j].style.color="#000";
			}
			e.target.style.backgroundColor="#fff";
			e.target.style.color="#0FBE79";
			/*右边出现相应的数据*/
	        $scope.lengths=res.data.filters.poi[this.$index].country;
	        if(this.$index==0){
	        	$scope.lengths=res.data.filters.poi[1].country;
	        }
	    }
	    
	});
	/*智能排序*/
	$scope.sort=function(e){
		// $scope.flag=false;
		$scope.a2=!$scope.a2;
		var lis=document.querySelectorAll(".shopChild_body_sort_li");
		for(var j=0;j<lis.length;j++){
			lis[j].style.color="#000";
		}
		e.target.style.color="#0FBE79";
		 $scope.flag = $scope.flag === true ? false : true;
		//$scope.orderKey=!$scope.orderKey;
	}
	/*更多筛选*/
	$scope.clickChange=function(e){
		var parents=document.querySelectorAll(".shopChild_evenyBody");
		for(var j=0;j<parents.length;j++){
			if(this.$index===j){
				var para=parents[this.$index].children[1].children;
				for(var i=0;i<para.length;i++){
					para[i].style.border="1px solid #dfdfdf";
					para[i].style.color="#000";
				}
				e.target.style.border="1px solid #0FBE79";
				e.target.style.color="#0FBE79";
			}
		}	
	}
	/*点击重置按钮的时候*/
	$scope.reverseClick=function(){
		document.querySelector(".shopChild_evenyBody_reverse").style.backgroundColor="#0FBE79";
		document.querySelector(".shopChild_evenyBody_reverse").style.color="#fff";
		document.querySelector(".shopChild_evenyBody_reverse2").style.backgroundColor="#fff";
		document.querySelector(".shopChild_evenyBody_reverse2").style.color="#0FBE79";
		var childrens=document.querySelectorAll(".shopChild_block_pEle_a");
		for(var i=0;i<childrens.length;i++){
			childrens[i].style.border="1px solid #dfdfdf";
			childrens[i].style.color="#000";
		}
		childrens[0].style.border="1px solid #0FBE79";
		childrens[0].style.color="#0FBE79";
		childrens[8].style.border="1px solid #0FBE79";
		childrens[8].style.color="#0FBE79";
		childrens[16].style.border="1px solid #0FBE79";
		childrens[16].style.color="#0FBE79";
	}
	/*点击确定的时候*/
	$scope.clickCON=function(){
		document.querySelector(".shopChild_evenyBody_reverse").style.backgroundColor="#fff";
		document.querySelector(".shopChild_evenyBody_reverse").style.color="#0FBE79";
		document.querySelector(".shopChild_evenyBody_reverse2").style.backgroundColor="#0FBE79";
		document.querySelector(".shopChild_evenyBody_reverse2").style.color="#fff";
	}
}])
